<?php 
    $row_number = 4;
    $jum_advs = 2;
    //$count_jobseeker = $this->requestAction(array('controller'=>'jobseekers','action'=>'get_count'));
    //$count_jobs = $this->requestAction(array('controller'=>'jobs','action'=>'get_count'));
?>

<SCRIPT LANGUAGE="JavaScript"> 
    function swap(id)
    {
        if(id==1)
        { document.getElementById('jobs_by').innerHTML=document.getElementById('category').innerHTML; }
        if(id==2)
        { document.getElementById('jobs_by').innerHTML=document.getElementById('location').innerHTML; }
        if(id==3)
        { document.getElementById('jobs_by').innerHTML=document.getElementById('career_level').innerHTML; }
    }   
    
    function swap_login(id)
    {
        if(id==1)
        { document.getElementById('login').innerHTML=document.getElementById('jobseeker').innerHTML; }
        if(id==2)
        { document.getElementById('login').innerHTML=document.getElementById('employer').innerHTML; }
    }    
    
    function open_win(id)
    {
        window.open('employers/view/'+id,"_blank","toolbar=no, location=yes, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=yes, top=100, left=100, width=930, height=600");
    }
    
</SCRIPT>


<table class='table_index'  cellspacing=0 >
    <tr>
        <td class='index_left'>
            <div id='login'> </div> 
            <hr color='#2A7EF7'>
            <div id='advs' style='margin-top:10px;'>
                <center>
                <?php echo $this->Element('adv_area'); ?>
                </center>
            </div>           
        </td>
        
        <td class='index_right' cellpadding='5px'>
            <div>
                <div id='information' style='float:left'>
                    Indonesia <br>
                    over <b> <?php echo $count_job; ?> </b> Jobs
                </div>
                <div id='information' style='float:left'>
                    Our member <br>
                    over <b> <?php echo $count_jobseeker; ?> </b> Jobseekers
                </div>  

                <div id='information' style='float:left'>
                    Our client <br>
                    over <b> <?php echo $count_employer; ?> </b> Employers
                </div>  

                <div id='information' style='float:left; '>
                    <font color='red'> <b>Job Posting Enquiry </b></font><br>
                    <a href='mailto:akhiyat.darmawan@gmail.com' ><u>akhiyat.darmawan@gmail.com</u></a>
                </div>  
                <br>
                <br>
                <br>
            </div>
            
            <div id='jobs_by'> </div>
            <div id='employers' >
            <br>
            <?php
                echo "<h2> &nbsp Top Employers</h2>";
                echo "<hr color='#2A7EF7'>"; 
                echo "<div id='top_company'><center>";
                foreach($top_employers as $employer)
                {
                    if($employer['employers']['logo']!='')
                    {
                        echo "<a href='javascript:open_win(".$employer['employers']['id'].")'>";
                        echo $html->image('../'.$employer['employers']['logo'],array('class'=>'logo'));
                        echo "</a>";
                        echo " &nbsp ";
                    }
                    else
                    {
                        echo $html->link($employer['employers']['company_name'],array('controller'=>'employers','action'=>'view','id'=>$employer['employers']['id']),array(),false,false);
                    }
                }
                echo "</center></div>";
                //echo $html->link('[ view all ]',array('controller'=>'employers','action'=>'view_all'),array('class'=>'sky'));
            ?>
            <div>            
        </td>
    </tr>
</table>


    <div id='category' style='display:none'>
        <?php
            echo "<table class='menu_jobs_by' cellspacing='0' ><tr>";
            echo "<td class='click'>Jobs by Category</td>";
            echo "<td class='normal'><a href='Javascript:swap(2);'>Jobs by Location</a></td>";
            echo "<td class='normal'><a href='Javascript:swap(3);'>Jobs by Career Level</a></td>";
            //echo "<td text-align='right'>".$html->link('[ Here ]',array('controller'=>'jobs','action'=>'search_result'))."</td>";
            echo "</tr></table>";
            echo $this->element('by_category',array('row_number'=>$row_number));
        ?>
    </div>


    <div id='location' style='display:none'>
        <?php
            echo "<table class='menu_jobs_by' cellspacing=0 ><tr>";
            echo "<td class='normal'><a href='Javascript:swap(1);'>Jobs by Category</a></td>";
            echo "<td class='click' >Jobs by Location</td>";
            echo "<td class='normal'><a href='Javascript:swap(3);'>Jobs by Career Level</a></td>";
            echo "</tr></table>"; 
            echo $this->element('by_location',array('row_number'=>$row_number)); 
        ?>
    </div>
    
    <div id='career_level' style='display:none'>
        <?php
            echo "<table class='menu_jobs_by' cellspacing=0 ><tr>";
            echo "<td class='normal'><a href='Javascript:swap(1);'>Jobs by Category</a></td>";
            echo "<td class='normal'><a href='Javascript:swap(2);'>Jobs by Location</a></td>";
            echo "<td class='click' >Jobs by Career Level</span></td>";
            echo "</tr></table>";
            echo $this->element('by_career',array('row_number'=>$row_number)); 
        ?>
    </div>
    
    <div id='jobseeker' style='display:none'>
    <?php
            
            if(isset($_SESSION['User']))
            { 
                $tipe_member = $_SESSION['User']['type']."s";
                echo "<div>";
                echo "<b>Welcome</b>, ".$_SESSION['User']['username']; 
                echo "<div style='text-align:right'>".$html->link('[ My Index ]',array('controller'=>$tipe_member,'action'=>'index'),array('class'=>'sky')); 
                echo "&nbsp".$html->link('[ Logout ]',array('controller'=>$tipe_member,'action'=>'logout'),array('class'=>'sky'))."</div>"; 
                echo "</div>";
            }
            else
            {
                echo "<span class='click'>Jobseeker Login</span>";
                echo "<span class='normal'><a href='Javascript:swap_login(2);'>[ Employer ]</a></span>";
                echo "<hr color='#2A7EF7'>"; 
                echo $form->create('Jobseeker',array('controller'=>'jobseekers','action'=>'login'));
                    echo $form->input('username',array ('maxLength'=>'20'));          
                    echo $form->input('password',array ('maxLength'=>'20'));
                echo "<div class='input'>";
                echo "<label>".$html->link('[ Sign Up ]',array('controller'=>'jobseekers','action'=>'signup'),array('class'=>'sky'))."</label>";
                echo "<input type='submit' value='Login'>";
                echo "</div>";
                echo "</form>";
            }
    
    ?>
    </div>
     
    <div id='employer' style='display:none'>
    <?php
            echo "<span class='click'>Employer Login</span>";
            echo "<span class='normal'><a href='Javascript:swap_login(1);'>[ Jobseeker ]</a></span>";
            echo "<hr color='#2A7EF7'>";
            echo $form->create('Employer',array('controller'=>'employers','action'=>'login'));
                echo $form->input('username',array ('maxLength'=>'20'));          
                echo $form->input('password',array ('maxLength'=>'20'));
            echo "<div class='input'>";
            echo "<label>".$html->link('[ Sign Up ]',array('controller'=>'employers','action'=>'signup'),array('class'=>'sky'))."</label>";
            echo "<input type='submit' value='Login'>";
            echo "</div>";
            echo "</form>";
    ?>
    </div>
    
<SCRIPT LANGUAGE="JavaScript"> 
    document.getElementById('jobs_by').innerHTML = document.getElementById('category').innerHTML    
    document.getElementById('login').innerHTML = document.getElementById('jobseeker').innerHTML    
</SCRIPT>
    
    
